
unit Files;

interface
uses
Winapi.Windows,
    Vcl.Graphics,

    Vcl.Controls,
    Vcl.Forms,
    Vcl.Dialogs,
    Vcl.ImgList,
    Vcl.Imaging.pngimage,
    Vcl.ExtCtrls,
    Vcl.ExtDlgs,
    Vcl.ToolWin,
    stroke,
    sysutils,
    Bitmap2;

function ChargerFichier() : TBitmap2;
FUNCTION OpenMyFile(sender: tform) : string;

implementation

function ChargerFichier() : TBitmap2;
var
  OpenPictureDialog1:TOpenPictureDialog;
  Picture: TPicture;
  original: Tbitmap2;
begin
  picture := TPicture.Create;
  OpenPictureDialog1 := TOpenPictureDialog.Create(nil);
  if OpenPictureDialog1.Execute then
  begin
    try
      picture.LoadFromFile(OpenPictureDialog1.FileName);
      original := TBitmap2.Create;
      original.CopyCanvas(picture);
      result := original ;
    finally
    end;
  end;
end;

FUNCTION OpenMyFile(sender: tform) : string;
    var
        openDialog : TOpenDialog;    // Open dialog variable
    begin
        openDialog := TOpenDialog.Create(sender);
        openDialog.InitialDir := GetCurrentDir;
        openDialog.Options := [ofFileMustExist];
        openDialog.Filter :='Fichier JPEG|*.jpg|Fichier BMP|*.bmp';
        openDialog.FilterIndex := 2;

        if openDialog.Execute
        then
            begin
            //ShowMessage('File : '+openDialog.FileName);
            result:= openDialog.FileName;
            end
        else
          begin
                ShowMessage('Open file was cancelled');
                end ;
        openDialog.Free;
    end;
end.
